package demo.practice.leetcode_eveyday;

public class P605 {


    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        //
        int sum=0;

        for(int i=0;i<flowerbed.length;i++){
            if((i==0 ||flowerbed[i-1]==0)&&(i==flowerbed.length-1||flowerbed[i+1]==0)&&flowerbed[i]==0){
                flowerbed[i]=1;//种上花
                sum+=1;
            }
        }
        return sum>=n;
    }
}
